package com.joysuch.wwyt.common.resultdto;

import lombok.Data;

import java.io.Serializable;

/**
 * @Description: token码表
 * @author: aeiSaf
 * @create: 2020-06-30 19:48
 **/
@Data
public class ApiResultDto implements Serializable {

    private static final long serialVersionUID = 5351535475812691532L;

    /**
     * 成功状态，ok表示成功，error表示失败
     */
    private String status;
    /**
     * 错误码。0，正常，其他不正常
     */
    private int errorCode;
    /**
     * 错误码。0，正常，其他不正常
     */
    private String errmsg;
    private Object data;


    public static ApiResultDto success() {
        return new ApiResultDto(ApiCodeMsgDto.SUCCESS);
    }

    public static ApiResultDto success(Object data) {
        return new ApiResultDto(ApiCodeMsgDto.SUCCESS, data);
    }

    public static ApiResultDto error(ApiCodeMsgDto apiCodeMsgDto ) {
        return new ApiResultDto(apiCodeMsgDto);
    }

    public static ApiResultDto error(ApiCodeMsgDto apiCodeMsgDto, String errmsg) {
        return new ApiResultDto(apiCodeMsgDto, errmsg);
    }

    public ApiResultDto() {
    }

    public ApiResultDto(String status, int errorCode, String errmsg, Object data) {
        this.status = status;
        this.errorCode = errorCode;
        this.errmsg = errmsg;
        this.data = data;
    }

    public ApiResultDto(ApiCodeMsgDto apiCodeMsgDto) {
        this.status = apiCodeMsgDto.getStatus();
        this.errorCode = apiCodeMsgDto.getErrorCode();
    }

    public ApiResultDto(ApiCodeMsgDto apiCodeMsgDto, Object data) {
        this.status = apiCodeMsgDto.getStatus();
        this.errorCode = apiCodeMsgDto.getErrorCode();
        this.data = data;
    }

    public ApiResultDto(ApiCodeMsgDto apiCodeMsgDto, String errmsg) {
        this.status = apiCodeMsgDto.getStatus();
        this.errorCode = apiCodeMsgDto.getErrorCode();
        this.errmsg = errmsg;
    }


}
